package com.intelligent.bot.api;

import com.intelligent.bot.base.exception.E;
import com.intelligent.bot.base.result.B;
import com.intelligent.bot.model.Video;
import com.intelligent.bot.model.base.BaseDeleteEntity;
import com.intelligent.bot.model.req.ClassifyAddReq;
import com.intelligent.bot.model.req.ClassifyAllocationReq;
import com.intelligent.bot.model.req.ClassifyGetVideoListReq;
import com.intelligent.bot.model.req.ClassifyUpdateReq;
import com.intelligent.bot.model.res.ClassifyListRes;
import com.intelligent.bot.service.IClassifyService;
import lombok.extern.log4j.Log4j2;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/sys/classify")
@Log4j2
@Transactional(rollbackFor = E.class)
public class ClassifyApi {

    @Resource
    IClassifyService classifyService;

    @RequestMapping(value = "list",name = "列表")
    public B<List<ClassifyListRes>> list()  {
        return classifyService.getList();
    }

    @RequestMapping(value = "add",name = "添加")
    public B<Void> add(@Validated @RequestBody ClassifyAddReq req)  {
        return classifyService.add(req);
    }


    @RequestMapping(value = "/update",name = "修改")
    public B<Void> update(@Validated @RequestBody ClassifyUpdateReq req)  {
        return classifyService.update(req);
    }

    @RequestMapping(value = "delete",name = "删除")
    public B<Void> delete(@Validated @RequestBody BaseDeleteEntity req)  {
        return classifyService.delete(req);
    }

    @RequestMapping(value = "allocation",name = "关联视频")
    public B<Void> allocation(@Validated @RequestBody ClassifyAllocationReq req)  {
        return classifyService.allocation(req);
    }

    @RequestMapping(value = "getVideoList",name = "查看视频列表")
    public B<List<Video>> getVideoList(@Validated @RequestBody ClassifyGetVideoListReq req)  {
        return classifyService.getVideoList(req);
    }

    @RequestMapping(value = "videoList",name = "视频列表")
    public B<List<Video>> videoList(@Validated @RequestBody ClassifyGetVideoListReq req)  {
        return classifyService.getVideoList(req);
    }

}
